package com.generator.dao.mybatis.mapper;

import com.generator.domain.Column;
import com.generator.domain.Table;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 数据库表结构查询
 * User: wangyanginfo
 * Date: 12-9-24
 * Time: 下午6:01
 *
 */
@Service("metaDataMapper")
public interface MetaDataMapper {

    @Select("SELECT table_name AS `name`,table_comment AS `comment` FROM tables WHERE table_schema = #{database}")
    public List<Table> queryTable(String database);

    @Select("SELECT column_name AS `name`,data_type AS typeName,column_key AS `key`,column_comment AS `comment` FROM columns WHERE table_schema = #{database} AND table_name = #{tableName}")
    public List<Column> queryColumn(Map<String, String> params);
}
